<?php

namespace App\Service\Third;

use App\Model\OcpcDouyin;
use App\Service\BaseService;

/**
 * 链接检测
 */
class DouYinAdService extends BaseService
{
    //https://xxx.com/callback/douyin_ad??promotionid=__PROMOTION_ID__&mid1=__MID1__&aid=__AID__&imei=__IMEI__&oaid=__OAID__&androidid=__ANDROIDID__&os=__OS__&TIMESTAMP=__TS__&callback=__CALLBACK_PARAM__
    public function handle()
    {
        $params = $this->request->all();

        log_info('dy监测链接===='.json_encode($params));
        $oaid = $params['oaid'] ?? '';
        $imei = $params['imei'] ?? '';
//        $channel = $params['cid'] ?? 0;

        if (OcpcDouyin::existsOaid($oaid)) {
            return 1;
        }

        if (OcpcDouyin::existImei($imei)) {
            return 1;
        }

        $ret = OcpcDouyin::addLog($params);

        log_info(__CLASS__ . "==Ret:{$ret}==Params:" . json_encode($params));

        return $ret;
    }

}